{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from pathlib import Path\n",
    "from single_nav_analysis import NavAnalysisConfig, SingleNavAnalysis\n",
    "from barra_data import BarraData"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "demo = BarraData(Path(r\"C:\\Euclid_Jie\\barra\\submodule\\nav_analysis\\barra_data\"))\n",
    "demo.update_data(\"cne5\")\n",
    "demo.update_data(\"cne6\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "开始读取衍复500S净值数据\n",
      "原始数据时间区间为：2022-07-08 ~ 2024-11-01\n",
      "本次统计时间区间为：2023-12-29 ~ 2024-11-01\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " WARNING  regression: Conditioon number for OLS X variables is large : 31 times over 31 periods\n"
     ]
    },
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "plotlyServerURL": "https://plot.ly"
       },
       "data": [
        {
         "alignmentgroup": "True",
         "hovertemplate": "name=dividend<br>index=%{x}<br>Value=%{y}<extra></extra>",
         "legendgroup": "dividend",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": ""
          }
         },
         "name": "dividend",
         "offsetgroup": "dividend",
         "orientation": "v",
         "showlegend": true,
         "textposition": "auto",
         "type": "bar",
         "x": [
          "2024-04-03T00:00:00",
          "2024-04-12T00:00:00",
          "2024-04-19T00:00:00",
          "2024-04-26T00:00:00",
          "2024-04-30T00:00:00",
          "2024-05-10T00:00:00",
          "2024-05-17T00:00:00",
          "2024-05-24T00:00:00",
          "2024-05-31T00:00:00",
          "2024-06-07T00:00:00",
          "2024-06-14T00:00:00",
          "2024-06-21T00:00:00",
          "2024-06-28T00:00:00",
          "2024-07-05T00:00:00",
          "2024-07-12T00:00:00",
          "2024-07-19T00:00:00",
          "2024-07-26T00:00:00",
          "2024-08-02T00:00:00",
          "2024-08-09T00:00:00",
          "2024-08-16T00:00:00",
          "2024-08-23T00:00:00",
          "2024-08-30T00:00:00",
          "2024-09-06T00:00:00",
          "2024-09-13T00:00:00",
          "2024-09-20T00:00:00",
          "2024-09-27T00:00:00",
          "2024-09-30T00:00:00",
          "2024-10-11T00:00:00",
          "2024-10-18T00:00:00",
          "2024-10-25T00:00:00",
          "2024-11-01T00:00:00"
         ],
         "xaxis": "x",
         "y": [
          -7.632557531154779,
          -7.030686949678584,
          -5.688170726074905,
          -5.713846951702983,
          -6.566292446947383,
          -2.8981541968040974,
          -6.151561300257473,
          -3.766487202726067,
          -7.994141832079759,
          -7.737901573123462,
          -3.1584175241862136,
          -3.1715837167353973,
          -2.659792412539595,
          -5.4071549763196955,
          -3.3929394166362177,
          -2.580133823661667,
          -1.1593398617047095,
          -2.804852375200916,
          -3.216739216325405,
          -4.375942202470399,
          -2.836660811404805,
          -5.262135238995034,
          -8.661605970092392,
          -4.708042146596775,
          -0.1478647540008171,
          8.378464100519986,
          10.68556117196681,
          7.297820367663489,
          4.927104645867605,
          6.247882570256767,
          6.105642084859788
         ],
         "yaxis": "y"
        },
        {
         "alignmentgroup": "True",
         "hovertemplate": "name=growth<br>index=%{x}<br>Value=%{y}<extra></extra>",
         "legendgroup": "growth",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": ""
          }
         },
         "name": "growth",
         "offsetgroup": "growth",
         "orientation": "v",
         "showlegend": true,
         "textposition": "auto",
         "type": "bar",
         "x": [
          "2024-04-03T00:00:00",
          "2024-04-12T00:00:00",
          "2024-04-19T00:00:00",
          "2024-04-26T00:00:00",
          "2024-04-30T00:00:00",
          "2024-05-10T00:00:00",
          "2024-05-17T00:00:00",
          "2024-05-24T00:00:00",
          "2024-05-31T00:00:00",
          "2024-06-07T00:00:00",
          "2024-06-14T00:00:00",
          "2024-06-21T00:00:00",
          "2024-06-28T00:00:00",
          "2024-07-05T00:00:00",
          "2024-07-12T00:00:00",
          "2024-07-19T00:00:00",
          "2024-07-26T00:00:00",
          "2024-08-02T00:00:00",
          "2024-08-09T00:00:00",
          "2024-08-16T00:00:00",
          "2024-08-23T00:00:00",
          "2024-08-30T00:00:00",
          "2024-09-06T00:00:00",
          "2024-09-13T00:00:00",
          "2024-09-20T00:00:00",
          "2024-09-27T00:00:00",
          "2024-09-30T00:00:00",
          "2024-10-11T00:00:00",
          "2024-10-18T00:00:00",
          "2024-10-25T00:00:00",
          "2024-11-01T00:00:00"
         ],
         "xaxis": "x",
         "y": [
          -6.508197822398976,
          -8.470788189378522,
          -10.618336482388319,
          -8.157887436691825,
          -5.2652591101488095,
          -4.883971645278159,
          -3.832602724456823,
          -2.8674773897099834,
          -4.687584111044198,
          -5.417863758022682,
          -3.617412286398387,
          -3.396466646212467,
          -2.4763207317681104,
          -6.317032547867821,
          -3.717709543753044,
          -1.7954543304794064,
          0.26468299550218344,
          -1.5437134420421699,
          -1.4531884139611089,
          -0.6061447864927791,
          -0.17562930093193518,
          2.7044015790023286,
          6.324120264453152,
          2.4623593181536476,
          2.8280617330679774,
          -0.8279273171921302,
          0.9664705162893066,
          -4.698390724057278,
          -3.4565997491473093,
          1.6918891715714168,
          3.01256210628096
         ],
         "yaxis": "y"
        },
        {
         "alignmentgroup": "True",
         "hovertemplate": "name=liquidity<br>index=%{x}<br>Value=%{y}<extra></extra>",
         "legendgroup": "liquidity",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": ""
          }
         },
         "name": "liquidity",
         "offsetgroup": "liquidity",
         "orientation": "v",
         "showlegend": true,
         "textposition": "auto",
         "type": "bar",
         "x": [
          "2024-04-03T00:00:00",
          "2024-04-12T00:00:00",
          "2024-04-19T00:00:00",
          "2024-04-26T00:00:00",
          "2024-04-30T00:00:00",
          "2024-05-10T00:00:00",
          "2024-05-17T00:00:00",
          "2024-05-24T00:00:00",
          "2024-05-31T00:00:00",
          "2024-06-07T00:00:00",
          "2024-06-14T00:00:00",
          "2024-06-21T00:00:00",
          "2024-06-28T00:00:00",
          "2024-07-05T00:00:00",
          "2024-07-12T00:00:00",
          "2024-07-19T00:00:00",
          "2024-07-26T00:00:00",
          "2024-08-02T00:00:00",
          "2024-08-09T00:00:00",
          "2024-08-16T00:00:00",
          "2024-08-23T00:00:00",
          "2024-08-30T00:00:00",
          "2024-09-06T00:00:00",
          "2024-09-13T00:00:00",
          "2024-09-20T00:00:00",
          "2024-09-27T00:00:00",
          "2024-09-30T00:00:00",
          "2024-10-11T00:00:00",
          "2024-10-18T00:00:00",
          "2024-10-25T00:00:00",
          "2024-11-01T00:00:00"
         ],
         "xaxis": "x",
         "y": [
          3.391660992371407,
          3.665404058402414,
          3.4626579544188765,
          3.366281818589763,
          3.38565469031876,
          1.988637960629586,
          2.883257071458045,
          -0.9650332488836901,
          1.1869771148649253,
          0.7077919396308028,
          -1.0415434052504489,
          -0.8058057576052697,
          -0.38526012299400536,
          -0.6378187666541215,
          -0.7933079672827869,
          -0.40193517933690187,
          -0.3942665221870403,
          -0.7401198907729757,
          0.07808357991474546,
          0.4930767784301732,
          0.9099545692016444,
          0.3995108527213499,
          -0.27239441596519154,
          0.9345605892143367,
          1.2009243692920197,
          -1.671966357007796,
          0.3801230817891339,
          -3.461915575583963,
          -3.211516453747705,
          -4.771645775480857,
          -4.742225994207067
         ],
         "yaxis": "y"
        },
        {
         "alignmentgroup": "True",
         "hovertemplate": "name=momentum<br>index=%{x}<br>Value=%{y}<extra></extra>",
         "legendgroup": "momentum",
         "marker": {
          "color": "#ab63fa",
          "pattern": {
           "shape": ""
          }
         },
         "name": "momentum",
         "offsetgroup": "momentum",
         "orientation": "v",
         "showlegend": true,
         "textposition": "auto",
         "type": "bar",
         "x": [
          "2024-04-03T00:00:00",
          "2024-04-12T00:00:00",
          "2024-04-19T00:00:00",
          "2024-04-26T00:00:00",
          "2024-04-30T00:00:00",
          "2024-05-10T00:00:00",
          "2024-05-17T00:00:00",
          "2024-05-24T00:00:00",
          "2024-05-31T00:00:00",
          "2024-06-07T00:00:00",
          "2024-06-14T00:00:00",
          "2024-06-21T00:00:00",
          "2024-06-28T00:00:00",
          "2024-07-05T00:00:00",
          "2024-07-12T00:00:00",
          "2024-07-19T00:00:00",
          "2024-07-26T00:00:00",
          "2024-08-02T00:00:00",
          "2024-08-09T00:00:00",
          "2024-08-16T00:00:00",
          "2024-08-23T00:00:00",
          "2024-08-30T00:00:00",
          "2024-09-06T00:00:00",
          "2024-09-13T00:00:00",
          "2024-09-20T00:00:00",
          "2024-09-27T00:00:00",
          "2024-09-30T00:00:00",
          "2024-10-11T00:00:00",
          "2024-10-18T00:00:00",
          "2024-10-25T00:00:00",
          "2024-11-01T00:00:00"
         ],
         "xaxis": "x",
         "y": [
          0.20348092245849714,
          0.3682956158087545,
          0.6088733514680587,
          0.056232198441165226,
          0.24577300038085959,
          0.4245937395405479,
          0.17452178810298702,
          1.9483588582518263,
          2.0521611706060185,
          1.73843331832498,
          0.8405794799770492,
          0.3083886597791303,
          0.5821334474089885,
          0.709812997568411,
          0.11549279516432043,
          -0.277311669128418,
          -0.46920017671273373,
          -0.32901690564426855,
          0.11611292918975386,
          0.27221756623019555,
          0.11968320650172673,
          -0.2246908395227526,
          -0.6354998608943835,
          -0.4142769407468541,
          -0.4378631151419652,
          -0.22957117688265533,
          1.2236979465634006,
          -0.20996823371032036,
          0.3258638106298246,
          0.9553749082004263,
          1.016877010078587
         ],
         "yaxis": "y"
        },
        {
         "alignmentgroup": "True",
         "hovertemplate": "name=quality<br>index=%{x}<br>Value=%{y}<extra></extra>",
         "legendgroup": "quality",
         "marker": {
          "color": "#FFA15A",
          "pattern": {
           "shape": ""
          }
         },
         "name": "quality",
         "offsetgroup": "quality",
         "orientation": "v",
         "showlegend": true,
         "textposition": "auto",
         "type": "bar",
         "x": [
          "2024-04-03T00:00:00",
          "2024-04-12T00:00:00",
          "2024-04-19T00:00:00",
          "2024-04-26T00:00:00",
          "2024-04-30T00:00:00",
          "2024-05-10T00:00:00",
          "2024-05-17T00:00:00",
          "2024-05-24T00:00:00",
          "2024-05-31T00:00:00",
          "2024-06-07T00:00:00",
          "2024-06-14T00:00:00",
          "2024-06-21T00:00:00",
          "2024-06-28T00:00:00",
          "2024-07-05T00:00:00",
          "2024-07-12T00:00:00",
          "2024-07-19T00:00:00",
          "2024-07-26T00:00:00",
          "2024-08-02T00:00:00",
          "2024-08-09T00:00:00",
          "2024-08-16T00:00:00",
          "2024-08-23T00:00:00",
          "2024-08-30T00:00:00",
          "2024-09-06T00:00:00",
          "2024-09-13T00:00:00",
          "2024-09-20T00:00:00",
          "2024-09-27T00:00:00",
          "2024-09-30T00:00:00",
          "2024-10-11T00:00:00",
          "2024-10-18T00:00:00",
          "2024-10-25T00:00:00",
          "2024-11-01T00:00:00"
         ],
         "xaxis": "x",
         "y": [
          2.5417156799209337,
          3.5650048449837444,
          5.157644264310747,
          2.3824461090117013,
          5.234397081474678,
          8.17172966314625,
          4.444612990077853,
          12.070039206134178,
          8.851753428698398,
          7.4043082451881705,
          9.623143682956606,
          9.66261272427059,
          11.769010796576024,
          22.33257980674477,
          9.761664521907225,
          7.328404162239272,
          8.516237798058548,
          6.229698832170563,
          6.005485798708444,
          6.051981928092012,
          5.389377815798239,
          3.034243356426237,
          0.0004741051346042191,
          3.3364342054040073,
          0.9569005638224157,
          7.115440975731808,
          3.440543711244265,
          14.994627365142785,
          12.475559573770571,
          14.345814915702558,
          14.914004602109149
         ],
         "yaxis": "y"
        },
        {
         "alignmentgroup": "True",
         "hovertemplate": "name=sentiment<br>index=%{x}<br>Value=%{y}<extra></extra>",
         "legendgroup": "sentiment",
         "marker": {
          "color": "#19d3f3",
          "pattern": {
           "shape": ""
          }
         },
         "name": "sentiment",
         "offsetgroup": "sentiment",
         "orientation": "v",
         "showlegend": true,
         "textposition": "auto",
         "type": "bar",
         "x": [
          "2024-04-03T00:00:00",
          "2024-04-12T00:00:00",
          "2024-04-19T00:00:00",
          "2024-04-26T00:00:00",
          "2024-04-30T00:00:00",
          "2024-05-10T00:00:00",
          "2024-05-17T00:00:00",
          "2024-05-24T00:00:00",
          "2024-05-31T00:00:00",
          "2024-06-07T00:00:00",
          "2024-06-14T00:00:00",
          "2024-06-21T00:00:00",
          "2024-06-28T00:00:00",
          "2024-07-05T00:00:00",
          "2024-07-12T00:00:00",
          "2024-07-19T00:00:00",
          "2024-07-26T00:00:00",
          "2024-08-02T00:00:00",
          "2024-08-09T00:00:00",
          "2024-08-16T00:00:00",
          "2024-08-23T00:00:00",
          "2024-08-30T00:00:00",
          "2024-09-06T00:00:00",
          "2024-09-13T00:00:00",
          "2024-09-20T00:00:00",
          "2024-09-27T00:00:00",
          "2024-09-30T00:00:00",
          "2024-10-11T00:00:00",
          "2024-10-18T00:00:00",
          "2024-10-25T00:00:00",
          "2024-11-01T00:00:00"
         ],
         "xaxis": "x",
         "y": [
          3.3986769473302876,
          4.4729388522867115,
          6.041837273434311,
          6.543243945773397,
          4.462449619449215,
          2.7067568468772913,
          2.8015458011143535,
          -3.475729728209827,
          2.593702668060577,
          3.8330135793827287,
          -3.16559637229588,
          -0.7876612792798382,
          -5.61776116656827,
          -12.15658344544011,
          -3.0571745218508797,
          -3.0020070582387737,
          -6.3982065204895004,
          0.3445291231381913,
          -2.733859124366937,
          -10.443737313620634,
          -8.82260858416423,
          -16.529699833153327,
          -25.961572448413015,
          -12.839789873411299,
          -3.245641171427664,
          3.706375152514063,
          15.002293779192964,
          -9.87773727590662,
          -9.343125678934703,
          -18.826782100908375,
          -22.002562369221337
         ],
         "yaxis": "y"
        },
        {
         "alignmentgroup": "True",
         "hovertemplate": "name=size<br>index=%{x}<br>Value=%{y}<extra></extra>",
         "legendgroup": "size",
         "marker": {
          "color": "#FF6692",
          "pattern": {
           "shape": ""
          }
         },
         "name": "size",
         "offsetgroup": "size",
         "orientation": "v",
         "showlegend": true,
         "textposition": "auto",
         "type": "bar",
         "x": [
          "2024-04-03T00:00:00",
          "2024-04-12T00:00:00",
          "2024-04-19T00:00:00",
          "2024-04-26T00:00:00",
          "2024-04-30T00:00:00",
          "2024-05-10T00:00:00",
          "2024-05-17T00:00:00",
          "2024-05-24T00:00:00",
          "2024-05-31T00:00:00",
          "2024-06-07T00:00:00",
          "2024-06-14T00:00:00",
          "2024-06-21T00:00:00",
          "2024-06-28T00:00:00",
          "2024-07-05T00:00:00",
          "2024-07-12T00:00:00",
          "2024-07-19T00:00:00",
          "2024-07-26T00:00:00",
          "2024-08-02T00:00:00",
          "2024-08-09T00:00:00",
          "2024-08-16T00:00:00",
          "2024-08-23T00:00:00",
          "2024-08-30T00:00:00",
          "2024-09-06T00:00:00",
          "2024-09-13T00:00:00",
          "2024-09-20T00:00:00",
          "2024-09-27T00:00:00",
          "2024-09-30T00:00:00",
          "2024-10-11T00:00:00",
          "2024-10-18T00:00:00",
          "2024-10-25T00:00:00",
          "2024-11-01T00:00:00"
         ],
         "xaxis": "x",
         "y": [
          -4.932246704458079,
          -5.07007494677642,
          -4.274376201826092,
          -4.866886252006326,
          -3.9632648374802213,
          -0.9470803881764036,
          -2.4256748768639644,
          2.037119930117285,
          -0.2559672241791384,
          -0.9686440625203127,
          0.23782175950479478,
          -0.9188740200054674,
          -0.44679387325248987,
          0.6750928722613179,
          -1.1683703091486661,
          -0.30098703251722814,
          0.650137946606886,
          -1.9571424517110718,
          -2.4955243682779376,
          -2.900028720503388,
          -2.78564986013804,
          -4.8258697254082685,
          -7.581776881552095,
          -4.797154821009495,
          -4.186456856608489,
          -7.7879245285334155,
          -1.9750042976805098,
          -14.058621208779684,
          -16.291144728487797,
          -24.573552611222652,
          -25.111818775417888
         ],
         "yaxis": "y"
        },
        {
         "alignmentgroup": "True",
         "hovertemplate": "name=value<br>index=%{x}<br>Value=%{y}<extra></extra>",
         "legendgroup": "value",
         "marker": {
          "color": "#B6E880",
          "pattern": {
           "shape": ""
          }
         },
         "name": "value",
         "offsetgroup": "value",
         "orientation": "v",
         "showlegend": true,
         "textposition": "auto",
         "type": "bar",
         "x": [
          "2024-04-03T00:00:00",
          "2024-04-12T00:00:00",
          "2024-04-19T00:00:00",
          "2024-04-26T00:00:00",
          "2024-04-30T00:00:00",
          "2024-05-10T00:00:00",
          "2024-05-17T00:00:00",
          "2024-05-24T00:00:00",
          "2024-05-31T00:00:00",
          "2024-06-07T00:00:00",
          "2024-06-14T00:00:00",
          "2024-06-21T00:00:00",
          "2024-06-28T00:00:00",
          "2024-07-05T00:00:00",
          "2024-07-12T00:00:00",
          "2024-07-19T00:00:00",
          "2024-07-26T00:00:00",
          "2024-08-02T00:00:00",
          "2024-08-09T00:00:00",
          "2024-08-16T00:00:00",
          "2024-08-23T00:00:00",
          "2024-08-30T00:00:00",
          "2024-09-06T00:00:00",
          "2024-09-13T00:00:00",
          "2024-09-20T00:00:00",
          "2024-09-27T00:00:00",
          "2024-09-30T00:00:00",
          "2024-10-11T00:00:00",
          "2024-10-18T00:00:00",
          "2024-10-25T00:00:00",
          "2024-11-01T00:00:00"
         ],
         "xaxis": "x",
         "y": [
          4.798245669071072,
          5.0044536360034515,
          4.333530994968878,
          4.269687144379631,
          3.186131127448642,
          2.6771259111500716,
          2.7071745330083465,
          0.1206090180222884,
          1.6653592961424375,
          1.435518416062807,
          0.3666692423693876,
          0.09431135987345884,
          0.28905531792639605,
          0.8705621008800841,
          0.17535548579922058,
          -0.7125350275214519,
          -0.7718898131144248,
          -0.5739338360529904,
          -0.7948437417163199,
          -1.4202386491796655,
          -0.9541622493186936,
          -0.8234905667800014,
          -0.4989546951383462,
          0.16757543653113516,
          0.9618275566043707,
          -0.29481313589754365,
          -1.5410091539470139,
          -1.6274164601671344,
          0.2896145944716171,
          0.1553329689312203,
          0.19604788224048003
         ],
         "yaxis": "y"
        },
        {
         "alignmentgroup": "True",
         "hovertemplate": "name=volatility<br>index=%{x}<br>Value=%{y}<extra></extra>",
         "legendgroup": "volatility",
         "marker": {
          "color": "#FF97FF",
          "pattern": {
           "shape": ""
          }
         },
         "name": "volatility",
         "offsetgroup": "volatility",
         "orientation": "v",
         "showlegend": true,
         "textposition": "auto",
         "type": "bar",
         "x": [
          "2024-04-03T00:00:00",
          "2024-04-12T00:00:00",
          "2024-04-19T00:00:00",
          "2024-04-26T00:00:00",
          "2024-04-30T00:00:00",
          "2024-05-10T00:00:00",
          "2024-05-17T00:00:00",
          "2024-05-24T00:00:00",
          "2024-05-31T00:00:00",
          "2024-06-07T00:00:00",
          "2024-06-14T00:00:00",
          "2024-06-21T00:00:00",
          "2024-06-28T00:00:00",
          "2024-07-05T00:00:00",
          "2024-07-12T00:00:00",
          "2024-07-19T00:00:00",
          "2024-07-26T00:00:00",
          "2024-08-02T00:00:00",
          "2024-08-09T00:00:00",
          "2024-08-16T00:00:00",
          "2024-08-23T00:00:00",
          "2024-08-30T00:00:00",
          "2024-09-06T00:00:00",
          "2024-09-13T00:00:00",
          "2024-09-20T00:00:00",
          "2024-09-27T00:00:00",
          "2024-09-30T00:00:00",
          "2024-10-11T00:00:00",
          "2024-10-18T00:00:00",
          "2024-10-25T00:00:00",
          "2024-11-01T00:00:00"
         ],
         "xaxis": "x",
         "y": [
          2.4416041541584415,
          2.4926277830613013,
          2.6113362082573115,
          2.4549906755090594,
          2.09997857476432,
          2.084993100636961,
          1.7626387613586902,
          1.6702907519967645,
          2.2959259369930627,
          2.105996553909755,
          1.3866900215686424,
          1.091523670448242,
          1.3585096388750002,
          1.6588696151298432,
          0.92494965947699,
          0.6260431588757017,
          0.7613807130626786,
          0.5885520082247091,
          0.6289690194609281,
          0.4940666212858089,
          0.4732573518089893,
          0.1998196179749504,
          -0.2456118590731452,
          0.13629317258836865,
          0.5554386751716749,
          1.3774677107519775,
          3.184291106397941,
          0.685322928145099,
          1.257411030947339,
          0.41461748966046574,
          0.21658331020732247
         ],
         "yaxis": "y"
        },
        {
         "line": {
          "color": "black"
         },
         "mode": "lines",
         "name": "R2",
         "type": "scatter",
         "x": [
          "2024-04-03T00:00:00.000000000",
          "2024-04-12T00:00:00.000000000",
          "2024-04-19T00:00:00.000000000",
          "2024-04-26T00:00:00.000000000",
          "2024-04-30T00:00:00.000000000",
          "2024-05-10T00:00:00.000000000",
          "2024-05-17T00:00:00.000000000",
          "2024-05-24T00:00:00.000000000",
          "2024-05-31T00:00:00.000000000",
          "2024-06-07T00:00:00.000000000",
          "2024-06-14T00:00:00.000000000",
          "2024-06-21T00:00:00.000000000",
          "2024-06-28T00:00:00.000000000",
          "2024-07-05T00:00:00.000000000",
          "2024-07-12T00:00:00.000000000",
          "2024-07-19T00:00:00.000000000",
          "2024-07-26T00:00:00.000000000",
          "2024-08-02T00:00:00.000000000",
          "2024-08-09T00:00:00.000000000",
          "2024-08-16T00:00:00.000000000",
          "2024-08-23T00:00:00.000000000",
          "2024-08-30T00:00:00.000000000",
          "2024-09-06T00:00:00.000000000",
          "2024-09-13T00:00:00.000000000",
          "2024-09-20T00:00:00.000000000",
          "2024-09-27T00:00:00.000000000",
          "2024-09-30T00:00:00.000000000",
          "2024-10-11T00:00:00.000000000",
          "2024-10-18T00:00:00.000000000",
          "2024-10-25T00:00:00.000000000",
          "2024-11-01T00:00:00.000000000"
         ],
         "y": [
          0.9793803669559933,
          0.9839298069861699,
          0.9785315128098453,
          0.9772906495884668,
          0.9829290797834642,
          0.9636590026980245,
          0.9556853887986266,
          0.9186459382272278,
          0.902770021612615,
          0.9365554674288401,
          0.8758201183807999,
          0.8731147271029909,
          0.8804808779654292,
          0.9378966353963687,
          0.8800559440196836,
          0.8416635761749672,
          0.820157940776811,
          0.7407777432794133,
          0.78933929893556,
          0.8582738556098573,
          0.8759284460627109,
          0.8937233576893528,
          0.8974455102577541,
          0.8462679500934328,
          0.7679953439553507,
          0.9051226958830586,
          0.9418700933837437,
          0.9005971998579333,
          0.9207605983897735,
          0.9791400215396676,
          0.9716619288408465
         ],
         "yaxis": "y2"
        }
       ],
       "layout": {
        "barmode": "relative",
        "legend": {
         "title": {
          "text": "name"
         },
         "tracegroupgap": 0
        },
        "template": {
         "data": {
          "bar": [
           {
            "error_x": {
             "color": "#2a3f5f"
            },
            "error_y": {
             "color": "#2a3f5f"
            },
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "bar"
           }
          ],
          "barpolar": [
           {
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "barpolar"
           }
          ],
          "carpet": [
           {
            "aaxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "baxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "type": "carpet"
           }
          ],
          "choropleth": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "choropleth"
           }
          ],
          "contour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "contour"
           }
          ],
          "contourcarpet": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "contourcarpet"
           }
          ],
          "heatmap": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmap"
           }
          ],
          "heatmapgl": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmapgl"
           }
          ],
          "histogram": [
           {
            "marker": {
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "histogram"
           }
          ],
          "histogram2d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2d"
           }
          ],
          "histogram2dcontour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2dcontour"
           }
          ],
          "mesh3d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "mesh3d"
           }
          ],
          "parcoords": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "parcoords"
           }
          ],
          "pie": [
           {
            "automargin": true,
            "type": "pie"
           }
          ],
          "scatter": [
           {
            "fillpattern": {
             "fillmode": "overlay",
             "size": 10,
             "solidity": 0.2
            },
            "type": "scatter"
           }
          ],
          "scatter3d": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatter3d"
           }
          ],
          "scattercarpet": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattercarpet"
           }
          ],
          "scattergeo": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergeo"
           }
          ],
          "scattergl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergl"
           }
          ],
          "scattermapbox": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattermapbox"
           }
          ],
          "scatterpolar": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolar"
           }
          ],
          "scatterpolargl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolargl"
           }
          ],
          "scatterternary": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterternary"
           }
          ],
          "surface": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "surface"
           }
          ],
          "table": [
           {
            "cells": {
             "fill": {
              "color": "#EBF0F8"
             },
             "line": {
              "color": "white"
             }
            },
            "header": {
             "fill": {
              "color": "#C8D4E3"
             },
             "line": {
              "color": "white"
             }
            },
            "type": "table"
           }
          ]
         },
         "layout": {
          "annotationdefaults": {
           "arrowcolor": "#2a3f5f",
           "arrowhead": 0,
           "arrowwidth": 1
          },
          "autotypenumbers": "strict",
          "coloraxis": {
           "colorbar": {
            "outlinewidth": 0,
            "ticks": ""
           }
          },
          "colorscale": {
           "diverging": [
            [
             0,
             "#8e0152"
            ],
            [
             0.1,
             "#c51b7d"
            ],
            [
             0.2,
             "#de77ae"
            ],
            [
             0.3,
             "#f1b6da"
            ],
            [
             0.4,
             "#fde0ef"
            ],
            [
             0.5,
             "#f7f7f7"
            ],
            [
             0.6,
             "#e6f5d0"
            ],
            [
             0.7,
             "#b8e186"
            ],
            [
             0.8,
             "#7fbc41"
            ],
            [
             0.9,
             "#4d9221"
            ],
            [
             1,
             "#276419"
            ]
           ],
           "sequential": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ],
           "sequentialminus": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ]
          },
          "colorway": [
           "#636efa",
           "#EF553B",
           "#00cc96",
           "#ab63fa",
           "#FFA15A",
           "#19d3f3",
           "#FF6692",
           "#B6E880",
           "#FF97FF",
           "#FECB52"
          ],
          "font": {
           "color": "#2a3f5f"
          },
          "geo": {
           "bgcolor": "white",
           "lakecolor": "white",
           "landcolor": "#E5ECF6",
           "showlakes": true,
           "showland": true,
           "subunitcolor": "white"
          },
          "hoverlabel": {
           "align": "left"
          },
          "hovermode": "closest",
          "mapbox": {
           "style": "light"
          },
          "paper_bgcolor": "white",
          "plot_bgcolor": "#E5ECF6",
          "polar": {
           "angularaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "radialaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "scene": {
           "xaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "yaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "zaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           }
          },
          "shapedefaults": {
           "line": {
            "color": "#2a3f5f"
           }
          },
          "ternary": {
           "aaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "baxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "caxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "title": {
           "x": 0.05
          },
          "xaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          },
          "yaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          }
         }
        },
        "title": {
         "text": "衍复500S Beta"
        },
        "xaxis": {
         "anchor": "y",
         "domain": [
          0,
          1
         ],
         "title": {
          "text": "日期"
         }
        },
        "yaxis": {
         "anchor": "x",
         "domain": [
          0,
          1
         ],
         "side": "right",
         "title": {
          "text": "敏感度"
         }
        },
        "yaxis2": {
         "overlaying": "y",
         "side": "left",
         "tickfont": {
          "color": "black"
         },
         "title": {
          "font": {
           "color": "black"
          },
          "text": "R2"
         }
        }
       }
      }
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "html路径为：C:\\Users\\Ouwei\\Desktop\\nav_data\\净值库1101\\按策略分\\500增强\\20231229_20241101_衍复500S_nav_analysis.html\n"
     ]
    }
   ],
   "source": [
    "nav_analysis_config = NavAnalysisConfig(\n",
    "    bench_data_path=Path(r\"C:\\Euclid_Jie\\barra\\src\\nav_analysis\\index_data.csv\"),\n",
    "    # nav_data_path=Path(r\"C:\\Users\\Ouwei\\Desktop\\管理人单页\\SLD035-同温层量化阿尔法1号.xlsx\"),\n",
    "    nav_data_path=Path(\n",
    "        r\"C:\\Users\\Ouwei\\Desktop\\nav_data\\净值库1101\\按策略分\\500增强\\衍复500S.xlsx\"\n",
    "    ),\n",
    "    begin_date=np.datetime64(\"2023-12-29\"),\n",
    "    # end_date=np.datetime64(\"2024-07-30\"),\n",
    "    open_html=False,\n",
    "    # benchmark=\"SHSE.000905\",\n",
    ")\n",
    "demo = SingleNavAnalysis(nav_analysis_config)\n",
    "demo.analysis()\n",
    "demo.attraction_analysis(\n",
    "    barra_rtn_df=pd.read_csv(r\"barra_data\\cne6.csv\"),\n",
    "    show=True,\n",
    "    R2=True,\n",
    ")\n",
    "demo.export_html()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
